#!/usr/bin/env python
##
# Title:        Diario 10minutos.com.uy News and Sports Calibre Recipe
# Contact:      Carlos Alves - <carlosalves90@gmail.com>
##
# License:      GNU General Public License v3 - http://www.gnu.org/copyleft/gpl.html
# Copyright:    Carlos Alves - <carlosalves90@gmail.com>
##
# Written:      September 2013
# Last Edited:  2018-02-13
##

__license__ = 'GPL v3'
__author__ = '2016, Carlos Alves <carlosalves90@gmail.com>'
'''
10minutos.com.uy
'''

from calibre.web.feeds.news import BasicNewsRecipe


class General(BasicNewsRecipe):
    title = '10minutos'
    __author__ = 'Carlos Alves'
    description = 'Noticias de Salto - Uruguay'
    tags = 'news, sports'
    language = 'es_UY'
    timefmt = '[%a, %d %b, %Y]'
    use_embedded_content = False
    recursion = 5
    encoding = 'utf8'
    remove_javascript = True
    no_stylesheets = True

    oldest_article = 2
    max_articles_per_feed = 100
    keep_only_tags = [dict(name='div', attrs={'class': 'post-content'})]

    remove_tags = [
        dict(name='div', attrs={'class': ['hr', 'titlebar', 'navigation']}),
        dict(name='div', attrs={'class': 'sharedaddy sd-sharing-enabled'}),
        dict(name='p', attrs={'class': 'post-meta'}),
        dict(name=['object', 'link'])
    ]

    extra_css = '''
                h1{font-family: Georgia,"Times New Roman",Times,serif}
                h3{font-family: Georgia,"Times New Roman",Times,serif}
                h2{font-family: Georgia,"Times New Roman",Times,serif}
                p{font-family: Verdana,Arial,Helvetica,sans-serif}
                body{font-family: Verdana,Arial,Helvetica,sans-serif}
                img{margin-bottom: 0.4em; display:block;}
                '''

    feeds = [
        (u'Articulos', u'http://10minutos.com.uy/?feed=rss2')
    ]

    def get_cover_url(self):
        return None

    def preprocess_html(self, soup):
        for item in soup.findAll(style=True):
            del item['style']
        return soup
